<?php

class SGN_FingerPrint {    
    public static function includeJs($namespace, $view, $devmode) {
        if ($devmode) {
            $conf = new Zend_Config_Xml(APPLICATION_PATH .  "/configs/$namespace/" . APPLICATION_ENV .".jsInclude.xml", $view, false);
            //TODO: xu ly truong hop module
            $array = $conf->toArray();
            $listjs = $array['js'];
            $scr = "";
            foreach ($listjs as $script) {
                $scr = $scr . "<script type='text/javascript' src=" . SGN_Application::get('imgUrl'). '/'.  $script . "> </script>";
            }
            return $scr;
        } else {
            $list = explode('.',$view);
            $fingerprint = SGN_Application::getConfig("gunny", "fingerprint");
            $array = $fingerprint->toArray();
            foreach ($list as $val) {
                $array = $array[$val];
            }
            return "<script type='text/javascript' src=" . SGN_Application::get('imgUrl'). "/js/compiled_js/" . $view . $array . ".js> </script>";
        }
    }
}